Dynomotion

Group: DynoMotion Message: 12516 From: rjreese29@ymail.com Date: 11/14/2015
Subject: Mpg at soft limit
Hi,
I wired an encoder to be an mpg and it is totally function. Super excited. It has also been integrated into thread 1. No other issues other than this 1 pseudo-bug.
When it hits soft limit it goes into feedhold. This is ok for me in kmotioncnc, because it is obvious with the flashing feedhold button. But in mach3, nothing is indicating this on the screen. My reset button fixes this and I can jog again. I know how to reset this in Mach, but it is not obvious for other people.

Is there a way to program MpgHardewareEnc.c to observe and treat soft limits like jogging might observe them?

For example, When jogging and a soft limit is hit, I can jog the other direction without having to reset or the machine going into feedhold.
In Mach, there is no indication of feedhold in Mach

I am a .c Luddite, but trying to learn
I will send my init file, when I am I front of my computer. Just thought I'd ask before hand.

Thanks!!!
Rob
Group: DynoMotion Message: 12541 From: rjreese29@ymail.com Date: 11/19/2015
Subject: Re: Mpg at soft limit

Hi,


Here is a little more information & a simplified question.


Would it be possible to modify some code in MpgSmoothHarewareEnc.c file (already integrated into my init thread), and have it observe softlimits without going into feedhold?

While using mach3, I can jog with this MPG until I hit a softlimit. When this happens, it goes into feedhold in Kmotion, but not in mach3.


I would like to see if there is someway to not have Kmotion go into feedhold if a softlimit is hit with use of the MPG.


Thank you for your help in these matters.


Attached is my init file.



Rob

  @@attachment@@
Group: DynoMotion Message: 12542 From: Hardy Family Date: 11/19/2015
Subject: Re: Mpg at soft limit [1 Attachment]
We based our MPG on that sample too.  What you want to do is insert something like the following just before the MoveExp() call:

#define TINYDIST 1  // number of steps to keep away from soft limit

            if (Target > chan[Axis].SoftLimitPos-TINYDIST)
               
Target = chan[Axis].SoftLimitPos-TINYDIST;
            if (
Target < chan[Axis].SoftLimitNeg+TINYDIST)
               
Target = chan[Axis].SoftLimitNeg+TINYDIST;

Regards,
SJH


On Thu, Nov 19, 2015 at 2:01 AM, rjreese29@... [DynoMotion] <DynoMotion@yahoogroups.com> wrote:
 
[Attachment(s) from rjreese29@... [DynoMotion] included below]

Hi,


Here is a little more information & a simplified question.


Would it be possible to modify some code in MpgSmoothHarewareEnc.c file (already integrated into my init thread), and have it observe softlimits without going into feedhold?

While using mach3, I can jog with this MPG until I hit a softlimit. When this happens, it goes into feedhold in Kmotion, but not in mach3.


I would like to see if there is someway to not have Kmotion go into feedhold if a softlimit is hit with use of the MPG.


Thank you for your help in these matters.


Attached is my init file.



Rob


Group: DynoMotion Message: 12543 From: Rjreese29 Date: 11/19/2015
Subject: Re: Mpg at soft limit
Hi,
That makes sense!! But we'll see if I can't put that to work/make that work over the weekend.

Thanks for your suggestion!!!

Rob

On Nov 19, 2015, at 8:52 AM, Hardy Family hardy.woodland.cypress@... [DynoMotion] <DynoMotion@yahoogroups.com> wrote:

 

We based our MPG on that sample too.  What you want to do is insert something like the following just before the MoveExp() call:

#define TINYDIST 1  // number of steps to keep away from soft limit

            if (Target > chan[Axis].SoftLimitPos-TINYDIST)
               
Target = chan[Axis].SoftLimitPos-TINYDIST;
            if (
Target < chan[Axis].SoftLimitNeg+TINYDIST)
               
Target = chan[Axis].SoftLimitNeg+TINYDIST;

Regards,
SJH


On Thu, Nov 19, 2015 at 2:01 AM, rjreese29@... [DynoMotion] <DynoMotion@yahoogroups.com> wrote:
 
[Attachment(s) from rjreese29@... [DynoMotion] included below]

Hi,


Here is a little more information & a simplified question.


Would it be possible to modify some code in MpgSmoothHarewareEnc.c file (already integrated into my init thread), and have it observe softlimits without going into feedhold?

While using mach3, I can jog with this MPG until I hit a softlimit. When this happens, it goes into feedhold in Kmotion, but not in mach3.


I would like to see if there is someway to not have Kmotion go into feedhold if a softlimit is hit with use of the MPG.


Thank you for your help in these matters.


Attached is my init file.



Rob



Group: DynoMotion Message: 12581 From: rjreese29@ymail.com Date: 12/10/2015
Subject: Re: Mpg at soft limit
Attachments :
Hi SJH,

Thanks again for the advice. I wasn't able to successfully integrate the code. I am not a programmer and do not understand an error I am getting when compiling thread 1

Error: function pointer expected.


Attached is a portion of the init.c where MPGSmoothHardwareEnc is integrated into thread 1
#define TINYDIST 100 is declared up at the top, but not on this file attached.

The section of code you gave me below is randomly placed right now on this file I attached.. 
Would anyone be able to show me how you would place this section of code without errors? ... Me being a newbie, 

I read a bit on function pointer errors,  but that didn't help.. 

As SJH advised, I placed this section just before the MoveExp() call and it also errored.

Any advice on how to do what he is suggesting would be greatly appreciated. Please review the attached file. I would like to see how these statements are properly syntaxed.

Thanks,
Rob
  @@attachment@@
Group: DynoMotion Message: 12582 From: Hardy Family Date: 12/10/2015
Subject: Re: Mpg at soft limit [1 Attachment]
Hi Rob,

where you currently have:

            if (Target > chan(2).SoftLimitPos-TINYDIST)
                Target = chan(2).SoftLimitPos-TINYDIST;
            if (Target < chan(2).SoftLimitNeg+TINYDIST)
                Target = chan(2).SoftLimitNeg+TINYDIST;

replace wherever you have "(2)" with "[Axis]" (without the quotes).  You are getting the "function pointer" error because, in C, the round brackets indicate parameters to a function.  So, where you write chan(2) the compiler is then expecting 'chan' to be the name of a function or a pointer to one.  But chan is really an array, so it needs to be indexed with square brackets.  Also, you don't want '2' in there, since then it would be comparing every axis to the limits for just the Z axis (number 2).  Since 'Axis' is the variable which contains the axis number that you are jogging, that is the appropriate index.

I know it's difficult to wrap your mind around (of all people, I had the greatest difficulty grokking arrays when I started programming, and C is definitely not a beginner's language).  Here's something that might be helpful in this case:

chan - is the name of an array
chan[n] - is the n'th element of chan.  C counts the first element as number 0, then counts up from there.  The joke is that you can tell someone is a C programmer because when counting how many fingers they have, they go "zero, one, two, three, four -  I have five fingers!"
chan[n].foo - is the field called 'foo' in the n'th element of chan.  On the kflop, there are a lot of useful fields in each channel element.  For example, SoftLimitPos.


Regards,
SJH



On Thu, Dec 10, 2015 at 9:22 AM, rjreese29@... [DynoMotion] <DynoMotion@yahoogroups.com> wrote:
 
[Attachment(s) from rjreese29@... [DynoMotion] included below]

Hi SJH,

Thanks again for the advice. I wasn't able to successfully integrate the code. I am not a programmer and do not understand an error I am getting when compiling thread 1

Error: function pointer expected.


Attached is a portion of the init.c where MPGSmoothHardwareEnc is integrated into thread 1
#define TINYDIST 100 is declared up at the top, but not on this file attached.

The section of code you gave me below is randomly placed right now on this file I attached.. 
Would anyone be able to show me how you would place this section of code without errors? ... Me being a newbie, 

I read a bit on function pointer errors,  but that didn't help.. 

As SJH advised, I placed this section just before the MoveExp() call and it also errored.

Any advice on how to do what he is suggesting would be greatly appreciated. Please review the attached file. I would like to see how these statements are properly syntaxed.

Thanks,
Rob


Group: DynoMotion Message: 12583 From: Rjreese29 Date: 12/10/2015
Subject: Re: Mpg at soft limit
Thanks SJH!! That makes sense
& That did the trick.

The explanation sends me down path of further learning and reading.  Your explanation makes good sense.

I over thought it and thought I had to call the axis#, now that I know it is an array...

Great to not have the not so obvious feedhold now!!!!

Thanks!

Rob

On Dec 10, 2015, at 10:49 AM, Hardy Family hardy.woodland.cypress@... [DynoMotion] <DynoMotion@yahoogroups.com> wrote:

 

Hi Rob,

where you currently have:

            if (Target > chan(2).SoftLimitPos-TINYDIST)
                Target = chan(2).SoftLimitPos-TINYDIST;
            if (Target < chan(2).SoftLimitNeg+TINYDIST)
                Target = chan(2).SoftLimitNeg+TINYDIST;

replace wherever you have "(2)" with "[Axis]" (without the quotes).  You are getting the "function pointer" error because, in C, the round brackets indicate parameters to a function.  So, where you write chan(2) the compiler is then expecting 'chan' to be the name of a function or a pointer to one.  But chan is really an array, so it needs to be indexed with square brackets.  Also, you don't want '2' in there, since then it would be comparing every axis to the limits for just the Z axis (number 2).  Since 'Axis' is the variable which contains the axis number that you are jogging, that is the appropriate index.

I know it's difficult to wrap your mind around (of all people, I had the greatest difficulty grokking arrays when I started programming, and C is definitely not a beginner's language).  Here's something that might be helpful in this case:

chan - is the name of an array
chan[n] - is the n'th element of chan.  C counts the first element as number 0, then counts up from there.  The joke is that you can tell someone is a C programmer because when counting how many fingers they have, they go "zero, one, two, three, four -  I have five fingers!"
chan[n].foo - is the field called 'foo' in the n'th element of chan.  On the kflop, there are a lot of useful fields in each channel element.  For example, SoftLimitPos.


Regards,
SJH



On Thu, Dec 10, 2015 at 9:22 AM, rjreese29@... [DynoMotion] <DynoMotion@yahoogroups.com> wrote:
 
[Attachment(s) from rjreese29@... [DynoMotion] included below]

Hi SJH,

Thanks again for the advice. I wasn't able to successfully integrate the code. I am not a programmer and do not understand an error I am getting when compiling thread 1

Error: function pointer expected.


Attached is a portion of the init.c where MPGSmoothHardwareEnc is integrated into thread 1
#define TINYDIST 100 is declared up at the top, but not on this file attached.

The section of code you gave me below is randomly placed right now on this file I attached.. 
Would anyone be able to show me how you would place this section of code without errors? ... Me being a newbie, 

I read a bit on function pointer errors,  but that didn't help.. 

As SJH advised, I placed this section just before the MoveExp() call and it also errored.

Any advice on how to do what he is suggesting would be greatly appreciated. Please review the attached file. I would like to see how these statements are properly syntaxed.

Thanks,
Rob